package com.hzit.controller;

import com.hzit.entity.PageResult;
import com.hzit.entity.R;
import com.hzit.entity.Student;
import com.hzit.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 类名：
 * 作者：WF
 * 功能：
 */
@RestController
@RequestMapping("/student")
public class StudentController {
	@Autowired
	private StudentService studentService;

	//1. 查询所有学生
	@GetMapping("/list")
	public R list(){
		List<Student> list = studentService.list();
		return R.ok().put("list",list);
	}
	//2. 条件查询带分页
	@PostMapping("/search/{page}/{pageSize}")
	public R search(@PathVariable("page") int page,
	                @PathVariable("pageSize") int pageSize,
	                @RequestBody Student student){
		System.out.println("student = " + student);
		PageResult<Student> pr = studentService.search(page,pageSize,student);
		return R.ok().put("pr",pr);
	}
}
